package com.igeek.boot.mapper;

import com.igeek.boot.entity.Admin;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.Set;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author author
 * @since 2023-12-26
 */
@Mapper
public interface AdminMapper extends BaseMapper<Admin> {

    //根据username查询admin信息(包含角色)
    @Select("select * from admin where username=#{username}")
    @Results({
            @Result(id = true,column = "id",property = "id"),
            @Result(
                    property = "roles",javaType = Set.class ,
                    column = "id",
                    many = @Many(select = "com.igeek.boot.mapper.RoleMapper.selectRolesByAdminId"))
    })
    public Admin selectAdminByName(String username);

}
